﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace Kinematic
{
    public class PathFolow : Class1
    {
        public List<Point> Camino;
        int index;
        private bool Acept;
        public PathFolow(List<Point> Camino) 
            :base()
        {
            Acept = false;
            this.Camino = Camino;
            index = 0;
        }

        public SteeringOutput Update(Kinematic THIS)
        {
            this.SetDA();
            SteeringOutput Strn = new SteeringOutput();
            int w = 4;
            int h = 4;

            if (index < Camino.Count)
            {
                int x = Camino[index].X;
                int y = Camino[index].Y;
                this.SetDA();
                Strn = this.DynamicArrive(THIS, new Kinematic(new Vector3(Camino[index].X, 0, Camino[index].Y), 0.0f));
                Rectangle K = new Rectangle(x - w / 2, y - h / 2, w, h);
                if (K.Contains((int)THIS.Position.X, (int)THIS.Position.Z))
                    index++;
            }
            else
            {
                Acept = true;
                Strn = this.Detener(THIS);
            }
            return Strn;
        }

        public bool Arrivate()
        {
            return Acept;
        }

    }
}
